<?php
     //引入配置文件
	require '../../public/config.php';
	require '../../public/mysql.php';
		//获取get传递的商品id
	$id = $_GET['id'];
	$link = connect();
	//准备sql和执行sql
	$sql = "select * from goods where id = '$id'";
	if ($link['error']) {
		$result = query($link['mess'], $sql);
	}
	$goods=$result;
	$sql = "select * from goodsimg where gid= '$id'";
	if ($link['error']) {
		$result = query($link['mess'], $sql);
	}
	$goodsimg=$result;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>s54管理中心 - 商品图片列表 </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../include/Css/general.css" rel="stylesheet" type="text/css" />
<link href="../include/Css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>
    <span class="action-span"><a href="__GROUP__/Goods/goodsAdd"></a></span>
    <span class="action-span1"><a href="__GROUP__">ECSHOP 管理中心</a></span>
    <span id="search_id" class="action-span1"> - 图片列表 </span>
    <div style="clear:both"></div>
</h1>
<div class="form-div">
    <form enctype="multipart/form-data" action="./action.php?a=addImg" method="post" >
		<input type="hidden" name="gid" value="<?php echo $id;?>">
        上传图片 <input type="file" name="image[]" size="15" multiple />
        <input type="submit" value="上传 " class="button" />
    </form>
</div>

<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="">
    <div class="list-div" id="listDiv">
        <table cellpadding="3" cellspacing="1">
            <tr>
                <th>编号</th>
                <th>商品名称</th>
                <th>商品图片</th>
                <th>商品子图片</th>
            </tr>
             <?php foreach ($goods as $val) :?>
            <tr>
                <td align="center"><?php echo $val['id']?></td>
                <td align="center" class="first-cell"><span><?php echo $val['name'];?></span></td>
				<?php  $path = '../../public/upload/'; ?>
				<!--原图 -->
                <td align="center" class="first-cell"><span><img width='50' src="<?php echo $path.$val['pic'];?>"></span></td>
				<!--子图 -->
				<td>
					<?php if(!empty($goodsimg)):?>
					<?php foreach ($goodsimg as $val) :?>
					<img width='50' src="<?php echo $path.$val['url'];?>">
					<a href = './action.php?a=delimg&id=<?php echo $val['id'] ?>&cid=<?php echo $val['gid'] ?>'>删除</a>
					<?php endforeach;?>
					<?php else: ?>
					<div align='center'>暂无子图</div>
					<?php endif?>
				</td>
				<!--操作 -->
                
            </tr>
            <?php endforeach;?>
        </table>

    <!-- 分页开始 -->
        <table id="page-table" cellspacing="0">
            <tr>
                <td width="80%">&nbsp;</td>
                <td align="center" nowrap="true">
                   
                </td>
            </tr>
        </table>
    <!-- 分页结束 -->
    </div>
</form>

<div id="footer">
共执行 7 个查询，用时 0.028849 秒，Gzip 已禁用，内存占用 3.219 MB<br />
版权所有 &copy; 2005-2012 暴走少年哈尔，并保留所有权利。</div>
</body>
</html>